package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.RepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MdjfCasePerson;
import com.ruoyi.system.service.IMdjfCasePersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部门办理相关人员Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@Api(tags = "部门办理相关人员管理")
@RestController
@RequestMapping("/system/person")
public class MdjfCasePersonController extends BaseController
{
    @Autowired
    private IMdjfCasePersonService mdjfCasePersonService;

    /**
     * 查询部门办理相关人员列表
     */
    @ApiOperation("查询参数列表")
    @PreAuthorize("@ss.hasPermi('system:person:list')")
    @GetMapping("/list")
    public TableDataInfo list(MdjfCasePerson mdjfCasePerson)
    {
        startPage();
        List<MdjfCasePerson> list = mdjfCasePersonService.selectMdjfCasePersonList(mdjfCasePerson);
        return getDataTable(list);
    }

    /**
     * 导出部门办理相关人员列表
     */
    @ApiOperation("导出参数列表")
//    @PreAuthorize("@ss.hasPermi('system:person:export')")
    @Log(title = "部门办理相关人员", businessType = BusinessType.EXPORT)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PostMapping("/export")
    public void export(HttpServletResponse response, MdjfCasePerson mdjfCasePerson)
    {
        List<MdjfCasePerson> list = mdjfCasePersonService.selectMdjfCasePersonList(mdjfCasePerson);
        ExcelUtil<MdjfCasePerson> util = new ExcelUtil<MdjfCasePerson>(MdjfCasePerson.class);
        util.exportExcel(response, list, "部门办理相关人员数据");
    }

    /**
     * 获取部门办理相关人员详细信息
     */
    @ApiOperation("获取部门办理相关人员详细信息")
//    @PreAuthorize("@ss.hasPermi('system:person:query')")
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @GetMapping(value = "/{personId}")
    public AjaxResult getInfo(@PathVariable("personId") Long personId)
    {
        return success(mdjfCasePersonService.selectMdjfCasePersonByPersonId(personId));
    }

    /**
     * 新增部门办理相关人员
     */
    @ApiOperation("新增部门办理相关人员")
//    @PreAuthorize("@ss.hasPermi('system:person:add')")
    @Log(title = "部门办理相关人员", businessType = BusinessType.INSERT)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PostMapping
    public AjaxResult add(@RequestBody MdjfCasePerson mdjfCasePerson)
    {
        return toAjax(mdjfCasePersonService.insertMdjfCasePerson(mdjfCasePerson));
    }

    /**
     * 修改部门办理相关人员
     */
    @ApiOperation("修改部门办理相关人员")
//    @PreAuthorize("@ss.hasPermi('system:person:edit')")
    @Log(title = "部门办理相关人员", businessType = BusinessType.UPDATE)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
    @PutMapping
    public AjaxResult edit(@RequestBody MdjfCasePerson mdjfCasePerson)
    {
        return toAjax(mdjfCasePersonService.updateMdjfCasePerson(mdjfCasePerson));
    }

    /**
     * 删除部门办理相关人员
     */
    @ApiOperation("删除部门办理相关人员")
//    @PreAuthorize("@ss.hasPermi('system:person:remove')")
    @Log(title = "部门办理相关人员", businessType = BusinessType.DELETE)
    @RepeatSubmit(interval = 1000, message = "请求过于频繁")
	@DeleteMapping("/{personIds}")
    public AjaxResult remove(@PathVariable Long[] personIds)
    {
        return toAjax(mdjfCasePersonService.deleteMdjfCasePersonByPersonIds(personIds));
    }
}
